
#define IRemote_Variable
#include "userDef.h"
#include "sysInit.h"
#define PerformanceTenSecond                    10

//#define OutAdcSensor5_1K
//#define OutAdcSensor10K                         
PerformanceTestType PerformanceTest =
{
    0
};


void PerformanceTestInit_2( void ) // 每次 切换模式 时候 赋初值
{
    if ( e_mode.set == MODECOOL ) // 制冷模式下 切换到 性能测试
    {
        PerformanceTest.VerticalAngle[0] = ver_Step.SwStep[SWCOOL][STEP3];
        PerformanceTest.VerticalAngle[1] = ver_Step.SwStep[SWCOOL][STEP3];
        PerformanceTest.HorizontalAngle[0] = ver_Step.SwStep[SWCOOL][STEP3];
        PerformanceTest.HorizontalAngle[1] = ver_Step.SwStep[SWCOOL][STEP3];
    }
    else // 制冷模式下 切换到 性能测试
    {
        PerformanceTest.VerticalAngle[0] = ver_Step.SwStep[SWHEAT][STEP5];
        PerformanceTest.VerticalAngle[1] = ver_Step.SwStep[SWHEAT][STEP5];
        PerformanceTest.HorizontalAngle[0] = ver_Step.SwStep[SWHEAT][STEP5];
        PerformanceTest.HorizontalAngle[1] = ver_Step.SwStep[SWHEAT][STEP5];
    }
}


void PerformanceTestInit( void ) //能力测试初始化
{
    memset( &PerformanceTest, 0, sizeof( PerformanceTest ) );

    /*
    PerformanceTest.VerticalAngle[0] =50;
    PerformanceTest.VerticalAngle[1] =50;
    PerformanceTest.HorizontalAngle[0]=50;
    PerformanceTest.HorizontalAngle[1]=50;
    */
}


void PerformanceTestDelay( void ) // 10S 计数
{
    if ( PerformanceTest.PerformanceTestOccurFlag == 0 )
    {
        if ( PerformanceTest.TenSecondCount > 0 )
        {
            PerformanceTest.TenSecondCount--;
        }

        if ( PerformanceTest.TenSecondCount == 0 )
        {
            PerformanceTest.RightLeftSwingCount = 0;
        }
    }

    if ( PerformanceTest.PerformanceTestOccurFlag == 1 ) //进入性能测试，5S才能调整频率
    {
        if ( PerformanceTest.CompFrequencyOffEn == 0 )
        {
            if ( ++PerformanceTest.CompFrequencyOffCount >= 5 )
            {
                PerformanceTest.CompFrequencyOffCount = 0;
                PerformanceTest.CompFrequencyOffEn = 1;
            }
        }
    }
}


void PerformanceTestClear( void ) // 清0
{
    memset( &PerformanceTest, 0, sizeof( PerformanceTest ) );

    /*
        PerformanceTest.VerticalAngle[0] =50;
        PerformanceTest.VerticalAngle[1] =50;
        PerformanceTest.HorizontalAngle[0]=50;
        PerformanceTest.HorizontalAngle[1]=50;
    */
}


void PerformanceTestHorizontalAngleAdd( void ) // 性能测试 导风角 加调节
{
    if ( PerformanceTest.PerformanceTestOccurFlag == 1 )
    {
        if ( e_mode.set == MODECOOL )
        {
            PerformanceTest.HorizontalAngle[SWCOOL] = PerformanceTest.HorizontalAngle[SWCOOL] +5;
        }
        else 
        {
            PerformanceTest.HorizontalAngle[SWHEAT] = PerformanceTest.HorizontalAngle[SWHEAT] +5;
        }
    }
}


void PerformanceTestHorizontalAngleSub( void ) // 性能测试 导风角 减调节
{
    if ( PerformanceTest.PerformanceTestOccurFlag == 1 )
    {
        if ( e_mode.set == MODECOOL )
        {
            PerformanceTest.HorizontalAngle[SWCOOL] = PerformanceTest.HorizontalAngle[SWCOOL] -5;
        }
        else 
        {
            PerformanceTest.HorizontalAngle[SWHEAT] = PerformanceTest.HorizontalAngle[SWHEAT] -5;
        }
    }
}


void IRemote_Init( void ) /* 红外遥控接收初始化 */
{
    U8      i;

    irCheck = 0;
    ir_Rec.bit = 0;
    ir_Rec.byte = 0;
    ir_Rec.interval = 0;
    ir_Rec.stat = 0;
    for ( i = 0; i < IREMOTEMAX; i++ )
    {
        buff_IR[i].byte = 0;
    }

    for ( i = 0; i < IREMOTEMAX_MB; i++ )
    {
        buff_IR_MB[i].byte = 0;
    }

    // R_TAU0_Channel3_Stop();
    TM40_Channel_Stop( TM4_CHANNEL_1 );
}


void IRemote_Intp( void ) /* 红外遥控接收中断处理 */
{
    U16     local_count;

    if ( irCheck == 0 && f_ADCEnd == ON && timer_powerOn >= 20 )
    {
        switch ( ir_Rec.stat )
        {
            case 0: // start receive
                if ( IO_IREMOTE == 0 )
                {
                    ir_Rec.stat = 1;

                    // R_TAU0_Channel3_Stop();
                    TM40_Channel_Stop( TM4_CHANNEL_1 );
                    __NOP();
                    __NOP();
                    __NOP();

                    // R_TAU0_Channel3_Start();
                    TM40_Channel_Start( TM4_CHANNEL_1 );
                    INTM->EGP1 = ( INTM->EGP1 | 0x02 ); // RISING EDGE
                    INTM->EGN1 = ( INTM->EGN1 | 0x02 );
                }
                else 
                {
                    IRemote_Init();
                    INTM->EGP1 = ( INTM->EGP1 & ( ~0x02 ) ); // FALLING EDGE
                    INTM->EGN1 = ( INTM->EGN1 | 0x02 );
                }

                break;

            case 1: // head low end
                if ( IO_IREMOTE == 1 )
                {
                    local_count = IRemote_Time();

                    // YD:6.74ms (5.74ms ~ 7.74ms)
                    // MB:6.10ms (5.10ms ~ 6.10ms)
                    if ( local_count >= 2550 && local_count <= 3870 )
                    {
                        ir_Rec.stat = 2; // adentech RC
                    }
                    else 
                    {
                        IRemote_Init();
                    }
                }
                else 
                {
                    ;
                }

                INTM->EGP1 = ( INTM->EGP1 & ( ~0x02 ) ); // FALLING EDGE
                INTM->EGN1 = ( INTM->EGN1 | 0x02 );
                break;

            case 2: // head high end
                if ( IO_IREMOTE == 0 )
                {
                    local_count = IRemote_Time();
                    if ( local_count >= 1185 && local_count <= 2185 ) // YD:3.37ms (2.37ms ~ 4.37ms)
                    {
                        ir_Rec.stat = 3;
                    }
                    else if ( local_count >= 3200 && local_count <= 4200 ) // MB:7.40ms (6.4ms ~ 8.4ms)
                    {
                        ir_Rec.stat = 4;
                    }
                    else 
                    {
                        IRemote_Init();
                    }
                }
                else 
                {
                    ;
                }

                break;

            case 3: // data
                if ( IO_IREMOTE == 0 )
                {
                    local_count = IRemote_Time();
                    if ( local_count >= 300 && local_count <= 600 ) // 0.84ms (0.6ms ~ 1.2ms)
                    {
                        buff_IR[ir_Rec.byte].byte >>= 1;
                    }
                    else if ( local_count >= 700 && local_count <= 1000 ) // 1.68ms (1.4ms ~ 2.0ms)
                    {
                        buff_IR[ir_Rec.byte].byte >>= 1;
                        buff_IR[ir_Rec.byte].byte |= 0x80;
                    }
                    else if ( local_count >= 11300 && local_count <= 14400 ) // 25.72ms (22.6ms ~ 28.8ms)
                    {
                        if ( ir_Rec.interval < 10 )
                        {
                            ir_Rec.interval++;
                        }

                        break;
                    }
                    else 
                    {
                        IRemote_Init();
                        break;
                    }

                    ir_Rec.bit++;
                    if ( ir_Rec.bit == 8 )
                    {
                        ir_Rec.bit = 0;
                        if ( ir_Rec.byte < IREMOTEMAX )
                        {
                            ir_Rec.byte++;
                        }
                    }
                }
                else 
                {
                    ;
                }

                break;

            case 4: // data
                if ( IO_IREMOTE == 0 )
                {
                    local_count = IRemote_Time();
                    if ( local_count >= 350 && local_count <= 750 ) // MB:0.54ms+0.54ms (0.7ms ~ 1.5ms)
                    {
                        buff_IR_MB[ir_Rec.byte].byte >>= 1;
                    }
                    else if ( local_count >= 800 && local_count <= 1350 ) // MB:1.62ms+0.54ms (1.6ms ~ 2.7ms)
                    {
                        buff_IR_MB[ir_Rec.byte].byte >>= 1;
                        buff_IR_MB[ir_Rec.byte].byte |= 0x80;
                    }
                    else if ( local_count >= 3500 && local_count <= 4500 ) // MB:7.4ms+0.54ms (7.00ms ~ 9.00ms)
                    {
                        ;
                    }
                    else 
                    {
                        IRemote_Init();
                        break;
                    }

                    ir_Rec.bit++;
                    if ( ir_Rec.bit == 8 )
                    {
                        ir_Rec.bit = 0;
                        if ( ir_Rec.byte < IREMOTEMAX_MB )
                        {
                            ir_Rec.byte++;
                        }
                    }
                }
                else 
                {
                    ;
                }

                break;

            default:
                break;
        }
    }
}


U16 IRemote_Time( void ) /* 红外遥控接收计时处理 */
{
    U16     local_count;

    if ( ( TM40->TDR01 ) >= ( TM40->TCR01 ) )
    {
        local_count = ( TM40->TDR01 ) - ( TM40->TCR01 );
    }
    else 
    {
        local_count = 0;
    }

    // R_TAU0_Channel3_Stop();
    TM40_Channel_Stop( TM4_CHANNEL_1 );
    __NOP();
    __NOP();
    __NOP();

    // R_TAU0_Channel3_Start();
    TM40_Channel_Start( TM4_CHANNEL_1 );
    return local_count;
}


void PerformanceTest_Sub_FanSpeed( void ) // 性能测试模式下的 风速调节
{
    if ( PerformanceTest.PerformanceTestOccurFlag == 1 )
    {
        if ( e_mode.set == MODEHEAT ) // 性能测试模式下 的制热的 风速调节
        {
            switch ( PerformanceTest.HeatInFanGear )
            {
                case 0:
                    PerformanceTest.SpeedAdjust[FANHEAT][0] = PerformanceTest.SpeedAdjust[FANHEAT][0] -10;
                    break;

                case 1:
                    PerformanceTest.SpeedAdjust[FANHEAT][1] = PerformanceTest.SpeedAdjust[FANHEAT][1] -10;
                    break;

                case 2:
                    PerformanceTest.SpeedAdjust[FANHEAT][2] = PerformanceTest.SpeedAdjust[FANHEAT][2] -10;
                    break;

                case 3:
                    PerformanceTest.SpeedAdjust[FANHEAT][3] = PerformanceTest.SpeedAdjust[FANHEAT][3] -10;
                    break;

                case 4:
                    PerformanceTest.SpeedAdjust[FANHEAT][4] = PerformanceTest.SpeedAdjust[FANHEAT][4] -10;
                    break;

                case 5:
                    PerformanceTest.SpeedAdjust[FANHEAT][5] = PerformanceTest.SpeedAdjust[FANHEAT][5] -10;
                    break;

                case 6:
                    PerformanceTest.SpeedAdjust[FANHEAT][6] = PerformanceTest.SpeedAdjust[FANHEAT][6] -10;
                    break;

                case 7:
                    PerformanceTest.SpeedAdjust[FANHEAT][7] = PerformanceTest.SpeedAdjust[FANHEAT][7] -10;
                    break;

                case 8:
                    PerformanceTest.SpeedAdjust[FANHEAT][8] = PerformanceTest.SpeedAdjust[FANHEAT][8] -10;
                    break;

                case 9:
                    PerformanceTest.SpeedAdjust[FANHEAT][9] = PerformanceTest.SpeedAdjust[FANHEAT][9] -10;
                    break;

                case 10:
                    PerformanceTest.SpeedAdjust[FANHEAT][10] = PerformanceTest.SpeedAdjust[FANHEAT][10] -10;
                    break;

                case 11:
                    PerformanceTest.SpeedAdjust[FANHEAT][11] = PerformanceTest.SpeedAdjust[FANHEAT][11] -10;
                    break;

                case 12:
                    PerformanceTest.SpeedAdjust[FANHEAT][12] = PerformanceTest.SpeedAdjust[FANHEAT][12] -10;
                    break;

                case 13:
                    PerformanceTest.SpeedAdjust[FANHEAT][13] = PerformanceTest.SpeedAdjust[FANHEAT][13] -10;
                    break;

                case 14:
                    PerformanceTest.SpeedAdjust[FANHEAT][14] = PerformanceTest.SpeedAdjust[FANHEAT][14] -10;
                    break;

                case 15:
                    PerformanceTest.SpeedAdjust[FANHEAT][15] = PerformanceTest.SpeedAdjust[FANHEAT][15] -10;
                    break;

                case 16:
                    PerformanceTest.SpeedAdjust[FANHEAT][16] = PerformanceTest.SpeedAdjust[FANHEAT][16] -10;
                    break;

                default:
                    ;
                    break;
            }
        }

        if ( e_mode.set == MODECOOL ) // 性能测试模式下 的制冷的 风速调节
        {
            switch ( PerformanceTest.CoolInFanGear )
            {
                case 0:
                    PerformanceTest.SpeedAdjust[FANCOOL][0] = PerformanceTest.SpeedAdjust[FANCOOL][0] -10;
                    break;

                case 1:
                    PerformanceTest.SpeedAdjust[FANCOOL][1] = PerformanceTest.SpeedAdjust[FANCOOL][1] -10;
                    break;

                case 2:
                    PerformanceTest.SpeedAdjust[FANCOOL][2] = PerformanceTest.SpeedAdjust[FANCOOL][2] -10;
                    break;

                case 3:
                    PerformanceTest.SpeedAdjust[FANCOOL][3] = PerformanceTest.SpeedAdjust[FANCOOL][3] -10;
                    break;

                case 4:
                    PerformanceTest.SpeedAdjust[FANCOOL][4] = PerformanceTest.SpeedAdjust[FANCOOL][4] -10;
                    break;

                case 5:
                    PerformanceTest.SpeedAdjust[FANCOOL][5] = PerformanceTest.SpeedAdjust[FANCOOL][5] -10;
                    break;

                case 6:
                    PerformanceTest.SpeedAdjust[FANCOOL][6] = PerformanceTest.SpeedAdjust[FANCOOL][6] -10;
                    break;

                case 7:
                    PerformanceTest.SpeedAdjust[FANCOOL][7] = PerformanceTest.SpeedAdjust[FANCOOL][7] -10;
                    break;

                case 8:
                    PerformanceTest.SpeedAdjust[FANCOOL][8] = PerformanceTest.SpeedAdjust[FANCOOL][8] -10;
                    break;

                case 9:
                    PerformanceTest.SpeedAdjust[FANCOOL][9] = PerformanceTest.SpeedAdjust[FANCOOL][9] -10;
                    break;

                case 10:
                    PerformanceTest.SpeedAdjust[FANCOOL][10] = PerformanceTest.SpeedAdjust[FANCOOL][10] -10;
                    break;

                case 11:
                    PerformanceTest.SpeedAdjust[FANCOOL][11] = PerformanceTest.SpeedAdjust[FANCOOL][11] -10;
                    break;

                case 12:
                    PerformanceTest.SpeedAdjust[FANCOOL][12] = PerformanceTest.SpeedAdjust[FANCOOL][12] -10;
                    break;

                case 13:
                    PerformanceTest.SpeedAdjust[FANCOOL][13] = PerformanceTest.SpeedAdjust[FANCOOL][13] -10;
                    break;

                case 14:
                    PerformanceTest.SpeedAdjust[FANCOOL][14] = PerformanceTest.SpeedAdjust[FANCOOL][14] -10;
                    break;

                case 15:
                    PerformanceTest.SpeedAdjust[FANCOOL][15] = PerformanceTest.SpeedAdjust[FANCOOL][15] -10;
                    break;

                case 16:
                    PerformanceTest.SpeedAdjust[FANCOOL][16] = PerformanceTest.SpeedAdjust[FANCOOL][16] -10;
                    break;

                default:
                    ;
                    break;
            }
        }
    }
}


void PerformanceTest_Add_FanSpeed( void ) // 性能测试模式下的 风速调节
{
    if ( PerformanceTest.PerformanceTestOccurFlag == 1 )
    {
        if ( e_mode.set == MODEHEAT ) // 性能测试模式下 的制热的 风速调节
        {
            switch ( PerformanceTest.HeatInFanGear )
            {
                case 0:
                    PerformanceTest.SpeedAdjust[FANHEAT][0] = PerformanceTest.SpeedAdjust[FANHEAT][0] +10;
                    break;

                case 1:
                    PerformanceTest.SpeedAdjust[FANHEAT][1] = PerformanceTest.SpeedAdjust[FANHEAT][1] +10;
                    break;

                case 2:
                    PerformanceTest.SpeedAdjust[FANHEAT][2] = PerformanceTest.SpeedAdjust[FANHEAT][2] +10;
                    break;

                case 3:
                    PerformanceTest.SpeedAdjust[FANHEAT][3] = PerformanceTest.SpeedAdjust[FANHEAT][3] +10;
                    break;

                case 4:
                    PerformanceTest.SpeedAdjust[FANHEAT][4] = PerformanceTest.SpeedAdjust[FANHEAT][4] +10;
                    break;

                case 5:
                    PerformanceTest.SpeedAdjust[FANHEAT][5] = PerformanceTest.SpeedAdjust[FANHEAT][5] +10;
                    break;

                case 6:
                    PerformanceTest.SpeedAdjust[FANHEAT][6] = PerformanceTest.SpeedAdjust[FANHEAT][6] +10;
                    break;

                case 7:
                    PerformanceTest.SpeedAdjust[FANHEAT][7] = PerformanceTest.SpeedAdjust[FANHEAT][7] +10;
                    break;

                case 8:
                    PerformanceTest.SpeedAdjust[FANHEAT][8] = PerformanceTest.SpeedAdjust[FANHEAT][8] +10;
                    break;

                case 9:
                    PerformanceTest.SpeedAdjust[FANHEAT][9] = PerformanceTest.SpeedAdjust[FANHEAT][9] +10;
                    break;

                case 10:
                    PerformanceTest.SpeedAdjust[FANHEAT][10] = PerformanceTest.SpeedAdjust[FANHEAT][10] +10;
                    break;

                case 11:
                    PerformanceTest.SpeedAdjust[FANHEAT][11] = PerformanceTest.SpeedAdjust[FANHEAT][11] +10;
                    break;

                case 12:
                    PerformanceTest.SpeedAdjust[FANHEAT][12] = PerformanceTest.SpeedAdjust[FANHEAT][12] +10;
                    break;

                case 13:
                    PerformanceTest.SpeedAdjust[FANHEAT][13] = PerformanceTest.SpeedAdjust[FANHEAT][13] +10;
                    break;

                case 14:
                    PerformanceTest.SpeedAdjust[FANHEAT][14] = PerformanceTest.SpeedAdjust[FANHEAT][14] +10;
                    break;

                case 15:
                    PerformanceTest.SpeedAdjust[FANHEAT][15] = PerformanceTest.SpeedAdjust[FANHEAT][15] +10;
                    break;

                case 16:
                    PerformanceTest.SpeedAdjust[FANHEAT][16] = PerformanceTest.SpeedAdjust[FANHEAT][16] +10;
                    break;

                default:
                    ;
                    break;
            }
        }

        if ( e_mode.set == MODECOOL ) // 性能测试模式下 的制冷的 风速调节
        {
            switch ( PerformanceTest.CoolInFanGear )
            {
                case 0:
                    PerformanceTest.SpeedAdjust[FANCOOL][0] = PerformanceTest.SpeedAdjust[FANCOOL][0] +10;
                    break;

                case 1:
                    PerformanceTest.SpeedAdjust[FANCOOL][1] = PerformanceTest.SpeedAdjust[FANCOOL][1] +10;
                    break;

                case 2:
                    PerformanceTest.SpeedAdjust[FANCOOL][2] = PerformanceTest.SpeedAdjust[FANCOOL][2] +10;
                    break;

                case 3:
                    PerformanceTest.SpeedAdjust[FANCOOL][3] = PerformanceTest.SpeedAdjust[FANCOOL][3] +10;
                    break;

                case 4:
                    PerformanceTest.SpeedAdjust[FANCOOL][4] = PerformanceTest.SpeedAdjust[FANCOOL][4] +10;
                    break;

                case 5:
                    PerformanceTest.SpeedAdjust[FANCOOL][5] = PerformanceTest.SpeedAdjust[FANCOOL][5] +10;
                    break;

                case 6:
                    PerformanceTest.SpeedAdjust[FANCOOL][6] = PerformanceTest.SpeedAdjust[FANCOOL][6] +10;
                    break;

                case 7:
                    PerformanceTest.SpeedAdjust[FANCOOL][7] = PerformanceTest.SpeedAdjust[FANCOOL][7] +10;
                    break;

                case 8:
                    PerformanceTest.SpeedAdjust[FANCOOL][8] = PerformanceTest.SpeedAdjust[FANCOOL][8] +10;
                    break;

                case 9:
                    PerformanceTest.SpeedAdjust[FANCOOL][9] = PerformanceTest.SpeedAdjust[FANCOOL][9] +10;
                    break;

                case 10:
                    PerformanceTest.SpeedAdjust[FANCOOL][10] = PerformanceTest.SpeedAdjust[FANCOOL][10] +10;
                    break;

                case 11:
                    PerformanceTest.SpeedAdjust[FANCOOL][11] = PerformanceTest.SpeedAdjust[FANCOOL][11] +10;
                    break;

                case 12:
                    PerformanceTest.SpeedAdjust[FANCOOL][12] = PerformanceTest.SpeedAdjust[FANCOOL][12] +10;
                    break;

                case 13:
                    PerformanceTest.SpeedAdjust[FANCOOL][13] = PerformanceTest.SpeedAdjust[FANCOOL][13] +10;
                    break;

                case 14:
                    PerformanceTest.SpeedAdjust[FANCOOL][14] = PerformanceTest.SpeedAdjust[FANCOOL][14] +10;
                    break;

                case 15:
                    PerformanceTest.SpeedAdjust[FANCOOL][15] = PerformanceTest.SpeedAdjust[FANCOOL][15] +10;
                    break;

                case 16:
                    PerformanceTest.SpeedAdjust[FANCOOL][16] = PerformanceTest.SpeedAdjust[FANCOOL][16] +10;
                    break;

                default:
                    ;
                    break;
            }
        }
    }
}


void IRemoteDecode( void ) /* 红外遥控解码 */
{
    U16     tempA;

    f_OutCSelf = 1;                     // 使能自清洁功能
    IRemoteCheck();
    if ( f_irCheck0 == 1 )
    {
        if ( IR_Custom == NORMCUSTOM || IR_Custom == TESTCUSTOM || IR_Custom == JUMPCUSTOM )
        {
            if ( ( ( IR_Data01 & 0x0F ) == 0x0C ) && ( f_coldOnly == 1 ) )
            {
                IRemote_Init();
                return;
            }

            if ( b_childlock.set == ON ) /* 童锁开启，不能遥控器 */
            {
                IRemote_Init();
                BuzzerAct( BUZZER400ms );
                dispTimer.childlock = 5;
                return;
            }

            if ( IR_Custom == JUMPCUSTOM )
            {
                if ( f_eepRom == IR_Data04_b0 && jumpType == ( IR_Data05 & 0x1F ) )
                {
                    f_quickTest = ON;
                    quickTest();
                }
                else 
                {
                    IRemote_Init();
                    return;
                }
            }

            if ( f_CleanSelf == 1 )
            {
                if ( IR_Data01_b3 == 0 )
                {
                    // stat_CleanSelf = CSELF_END;
                    // CleanSelfMode();
                }
                else 
                {
                    IRemote_Init();
                    return;
                }
            }

#ifdef WINE_CELLAR_MODE
            if ( ( IR_Data01 & 0x07 ) == 0x00 || ( IR_Data01 & 0x07 ) == 0x04 )
            {
                IRemote_Init();
                return;
            }

#endif

            /* iremote set power */
            set_power( IR_Data01_b3 );

            /* power change for long buzzer */
            if ( f_chg_power == FALSE )
            {
                BuzzerAct( BUZZER100ms );
            }
            else 
            {
                BuzzerAct( BUZZER200ms );
            }

            /* iremote set mode */
            set_mode( IR_Data01 & 0x07 );
            if ( IR_Custom != JUMPCUSTOM )
            {
                /* iremote set eco */
                set_eco( IR_Data04_b0 );

                /* iremote set lowheat */
                set_lowheat( IR_Data04_b0 );
            }
            else 
            {
                set_eco( OFF );
                set_lowheat( OFF );
            }

            /* iremote set fanStep */
            if ( IR_Data01_b7 == 1 )
            {
                set_fanStep( FANLEVEL7 );
            }
            else if ( IR_Data02_b6 == 1 )
            {
                set_fanStep( FANLEVEL1 );
            }
            else 
            {
                if ( ( ( IR_Data01 & 0x70 ) >> 4 ) == 0x00 )
                {
                    set_fanStep( FANAUTO );
                }
                else if ( ( ( IR_Data01 & 0x70 ) >> 4 ) < 0x06 )
                {
                    set_fanStep( ( ( IR_Data01 & 0x70 ) >> 4 ) * 20 - 10 );
                }
                else 
                {
                    if ( IR_Data11 == 0x00 )
                    {
                        set_fanStep( 0x01 );
                    }
                    else 
                    {
                        set_fanStep( IR_Data11 );
                    }
                }
            }

#ifndef WINE_CELLAR_MODE
            set_tempUnit( IR_Data02_b5 );
            if ( IR_Data02_b4 == 0 )
            {
                tempA   = ( ( IR_Data02 & 0x0F ) + 16 ) * 10;
            }
            else 
            {
                tempA   = ( ( IR_Data02 & 0x0F ) + 16 ) * 10 + 5;
            }

#else

            set_tempUnit( 0 );
            if ( IR_Data02_b4 == 0 )
            {
                tempA   = ( ( IR_Data02 & 0x0F ) + 10 ) * 10;
            }
            else 
            {
                tempA   = ( ( IR_Data02 & 0x0F ) + 10 ) * 10 + 5;
            }

#endif

            set_tartemp( tempA, ( ( U16 ) ( tempA * 1.8 ) + 320 ) / 10 * 10 );

            /* iremote set verSwing */
            set_verSw( IR_Data03 & 0x0F );

            /* iremote set horSwing */
            set_horSw( ( IR_Data03 & 0xF0 ) >> 4 );

            /* iremote set light */
            set_light( IR_Data04_b7 );

            /* iremote set sleep */
            set_sleep( IR_Data04_b1 );

            /* iremote set health */
            set_health( IR_Data04_b6 );

            /* iremote set keephum */
            if ( IR_Data04_b5 == 1 )
            {
                if ( f_SetKeepHum == 1 )
                {
                    f_SetKeepHum = 0;
                }
                else 
                {
                    f_SetKeepHum = 1;
                    f_code_HC = 1;
                }
            }

            /* iremote set dryer */
            set_dryer( IR_Data04_b4 );

            /* iremote set heater */
            set_heater( IR_Data04_b4 );
            stat_Disp888 = ( IR_Data04 & 0x0C ) >> 2;
            if ( IR_Custom != JUMPCUSTOM && IR_Data05_b6 == 1 )
            {
                temp.IFeel = ( IR_Data05 & 0x3F ) * 10;
                timer_IFeelSec = 660;
            }
            else 
            {
                temp.IFeel = 0;
            }

            if ( f_irCheck1 == 1 )
            {
                /* iremote set timerOn */
                set_timerOn( ( ( U16 ) ( IR_Data06 & 0x07 ) << 8 ) +IR_Data07 );

                /* iremote set timerOff */
                set_timerOff( ( ( U16 ) ( IR_Data06 & 0x70 ) << 4 ) +IR_Data08 );
                if ( ( IR_Data09 & 0xF0 ) != 0x00 )
                {
                    set_tarHum( ( U16 ) ( ( ( IR_Data09 & 0xF0 ) >> 4 ) + 3 ) * 50 );
                }

                /* iremote set humidifier */
                set_humidifier( IR_Data09_b3 );
                f_wifi_rst = IR_Data09_b1;
                f_wifi_test = IR_Data09_b0;

                /* iremote set call display */
                if ( IR_Data10_b2 == 1 )
                {
                    if ( CallDispMin == 0 )
                    {
                        BuzzerAct( BUZZER400ms );
                        CallDispMin = 5;
                        if ( parameter_out.indoorNum > 1 )
                        {
                            dispTimer.adrr = 30;
                        }
                    }
                    else 
                    {
                        CallDispMin = 0;
                    }
                }

                /* iremote set no check dewing */
                if ( IR_Data10_b7 == 1 )
                {
                    f_eepRomW = 1;
                    if ( f_SetNoCheckDewing == 1 )
                    {
                        f_code_o6 = 0;
                        f_SetNoCheckDewing = 0;
                    }
                    else 
                    {
                        f_code_o6 = 1;
                        f_SetNoCheckDewing = 1;
                        BuzzerAct( BUZZER400ms );
                    }
                }

                /* iremote set cleanself */
                if ( IR_Data10_b6 == 1 && f_CleanSelf == 0 )
                {
                    if ( temp.roomAct < 160 || temp.roomAct > 380 || temp.outdoor < ( 400 + 0 ) || temp.outdoor > ( 400 + 430 ) || ( temp.roomAct > 300 && temp.outdoor > ( 400 + 400 ) ) )
                    {
                        ;
                    }
                    else 
                    {
                        if ( f_OutCSelf == 1 )
                        {
                            f_CleanSelf = 1;
                            stat_CleanSelf = CSELF_ACT;
                            BuzzerAct( BUZZER400ms );
                        }
                    }
                }

                /* iremote set no check fo */
                if ( IR_Data10_b5 == 1 )
                {
                    f_eepRomW = 1;
                    if ( f_SetNoCheckFo == 1 )
                    {
                        f_code_o4 = 0;
                        f_SetNoCheckFo = 0;
                    }
                    else 
                    {
                        f_code_o4 = 1;
                        f_SetNoCheckFo = 1;
                        BuzzerAct( BUZZER400ms );
                    }
                }

                /* iremote set force defrost */
                if ( ( IR_Data10 & 0x03 ) == 0x03 && TestRunStat == 0 && f_OutErr_Ub == 0 )
                {
                    set_manual_defrost( ON );
                    BuzzerAct( BUZZER400ms );
                }

                if ( IR_Custom == TESTCUSTOM )
                {
                    f_SetCapTest = IR_Data10_b4;
                    SetTestTimeMin = IR_Data11;
                    SetTestTimeHour = IR_Data12;
                }
                else 
                {
                    f_SetCapTest = 0;
                    SetTestTimeMin = 0;
                    SetTestTimeHour = 0;
                }
            }
            else 
            {
                set_timerOn( 0 );
                set_timerOff( 0 );
                f_wifi_rst = OFF;
                f_wifi_test = 0;
                f_SetCapTest = 0;
                SetTestTimeMin = 0;
                SetTestTimeHour = 0;
            }

            TestRunSet();
            if ( IR_Custom == TESTCUSTOM )
            {
                TestStatSet();
                if ( CapTestStat != 0 && f_chg_verSw == TRUE ) // UD Swing Change
                {
                    f_TestSwChg = 1;
                }
                else if ( CapTestStat == 0 )
                {
                    f_TestSwChg = 0;
                }

                if ( SetFreValue != 0 && f_chg_fanstep == TRUE ) // Fan Change
                {
                    f_TestFanChg = 1;
                }
                else if ( SetFreValue == 0 )
                {
                    f_TestFanChg = 0;
                }
            }
            else 
            {
                ClrTestValue();
                FoRecallSet();
                tuya_app_set_test();
                tuya_app_show_data();
                if ( PowerOnMin < 2 && b_power.set == ON )
                {
                    eepRomReset();
                    TempRepairReset();
                    if ( ( IR_Data01 & 0x70 ) == 0x60 )
                    {
                        JumpTypeReset( IR_Data11 );
                    }

                    //tarTemp_limit_set(); // 屏蔽掉酒店模式
                }
            }

            /* 只要收到遥控就清 */
            if ( f_FilterClean == TRUE )
            {
                f_FilterClean = FALSE;
            }

            f_eepRomChg = 1;
            CtrlEndTime = 0;
        }
        else if ( IR_Custom == 0xD0 )
        {
            temp.IFeel = IR_Data01 * 10;
            timer_IFeelSec = 660;
            set_timerOn( ( ( U16 ) ( IR_Data03 & 0x07 ) << 8 ) +IR_Data02 );
            set_timerOff( ( ( U16 ) ( IR_Data03 & 0x07 ) << 8 ) +IR_Data04 );
            TimerActSec = 0;
        }

#ifdef CTRL_485
        update_wireCtrl = 2;
#endif

        IRemote_Init();
    }

    if ( f_irCheck3 == 1 )
    {
        if ( b_childlock.set == ON ) /* 童锁开启，不能遥控器 */
        {
            IRemote_Init();
            BuzzerAct( BUZZER400ms );
            dispTimer.childlock = 5;
            return;
        }

        if ( ( ( EntranceGuard.FucOpen == EntranceGuardON ) && ( EntranceGuard.EntranceGuardConnectMachineOnState == EntranceGuardConnectMachineOn ) ) || EntranceGuard.FucOpen == EntranceGuardOFF ) // 闂ㄧ鍔熻兘浣胯兘涓旈棬鍗℃彃鍏ユ垨鑰呴棬绂佸姛鑳芥湭浣胯兘锛屾墠鑳芥墽琛屽紑鍏虫満
        {
            set_power( buff_IR_MB[2 * 3 + 1].bit.b1 );
        }
        else if ( ( EntranceGuard.FucOpen == EntranceGuardON ) && ( EntranceGuard.EntranceGuardConnectMachineOnState == EntranceGuardConnectMachineOff ) )
        {
            set_power( OFF );
        }

        /*
                if ( ( b_power.set == ON ) && ( buff_IR_MB[2 * 3 + 1].bit.b4 == 1 ) && ( e_mode.run == MODEDRY ) ) // 按下左右扫风 且 是除湿模式 蜂鸣器不鸣叫
                {
                    RightLeftBuzFlag = 1;
                    IRemote_Init();
                    return;
                }

                if ( ( RightLeftBuzFlag == 1 ) && ( b_power.set == ON ) && ( buff_IR_MB[2 * 3 + 1].bit.b4 == 0 ) && ( e_mode.run == MODEDRY ) )
                {
                    RightLeftBuzFlag = 0;
                    IRemote_Init();
                    return;
                }
        */
        // if (f_CleanSelf == 1)
        // {
        //     if (IR_Data01_b3 == 0)
        //     {
        //         stat_CleanSelf = CSELF_END;
        //         CleanSelfMode();
        //     }
        //     else
        //     {
        //         IRemote_Init();
        //         return;
        //     }
        // }

        /* iremote set power */
        set_power( buff_IR_MB[2 * 3 + 1].bit.b1 );

        /* power change for long buzzer */
        if ( f_chg_power == FALSE )
        {
            BuzzerAct( BUZZER100ms );
        }
        else 
        {
            BuzzerAct( BUZZER200ms );
        }

        /* iremote set mode */
        set_mode( ( buff_IR_MB[2 * 4 + 1].byte >> 5 ) & 0x07 );

        /* iremote set eco */
        set_eco( buff_IR_MB[2 * 1 + 1].bit.b4 );

        /* iremote set lowheat */
        // set_lowheat(IR_Data04_b0);
        AdjHorSw_2( buff_IR_MB[2 * 1 + 1].bit.b3 ); // 按下 遥控器的强风按键

        /* iremote set fanStep */
        if ( buff_IR_MB[2 * 1 + 1].bit.b3 )
        {
            set_fanStep( FANLEVEL7 );
        }
        else if ( buff_IR_MB[2 * 1 + 1].bit.b6 )
        {
            set_fanStep( FANLEVEL1 );
        }
        else 
        {
            if ( ( ( buff_IR_MB[2 * 3 + 1].byte >> 5 ) & 0x03 ) == 1 )
            {
                set_fanStep( FANLEVEL6 );
            }
            else if ( ( ( buff_IR_MB[2 * 3 + 1].byte >> 5 ) & 0x03 ) == 2 )
            {
                set_fanStep( FANLEVEL4 );
            }
            else if ( ( ( buff_IR_MB[2 * 3 + 1].byte >> 5 ) & 0x03 ) == 3 )
            {
                set_fanStep( FANLEVEL2 );
            }
            else 
            {
                set_fanStep( FANAUTO );
            }
        }

        // #ifndef WINE_CELLAR_MODE
        set_tempUnit( buff_IR_MB[2 * 3 + 1].bit.b7 ); // 摄氏/华氏
        if ( buff_IR_MB[2 * 3 + 1].bit.b7 == 0 )
        {
            if ( ( buff_IR_MB[2 * 4 + 1].byte & 0x1F ) > 0x10 )
            {
                tempA   = ( 0x10 + 16 ) * 10;
            }
            else 
            {
                tempA   = ( ( buff_IR_MB[2 * 4 + 1].byte & 0x1F ) + 16 ) * 10;
            }

            set_tartemp( tempA, ( ( U16 ) ( tempA * 1.8 ) + 320 ) / 10 * 10 );
        }
        else 
        {
            if ( ( buff_IR_MB[2 * 4 + 1].byte & 0x1F ) > 0x1D )
            {
                tempA   = ( 0x1D + 61 ) * 10;
            }
            else 
            {
                tempA   = ( ( buff_IR_MB[2 * 4 + 1].byte & 0x1F ) + 61 ) * 10;
            }

            set_tartemp( ( ( ( tempA - 320 ) / 1.8 ) + 5 ) / 10 * 10, tempA );
        }

        // #else
        //         set_tempUnit(0);
        //         if (IR_Data02_b4 == 0)
        //         {
        //             tempA = ((IR_Data02 & 0x0F) + 10) * 10;
        //         }
        //         else
        //         {
        //             tempA = ((IR_Data02 & 0x0F) + 10) * 10 + 5;
        //         }
        // #endif

        /* iremote set verSwing */
        if ( ( ( buff_IR_MB[2 * 3 + 1].byte >> 2 ) & 0x03 ) == 1 )
        {
            set_verSw( 1 );
            if ( ( PerformanceTest.PerformanceTestOccurFlag == 1 ) && ( PerformanceTest.CompFrequencyOffEn == 1 ) )
            {
                PerformanceTest.CompFrequencyOffset = PerformanceTest.CompFrequencyOffset + 1;
            }
        }
        else 
        {
            set_verSw( 0 );
        }

        /* iremote set horSwing */
        if ( buff_IR_MB[2 * 3 + 1].bit.b4 == 0 )
        {
            set_horSw( 1 );
            if ( ( PerformanceTest.PerformanceTestOccurFlag == 1 ) && ( PerformanceTest.CompFrequencyOffEn == 1 ) )
            {
                PerformanceTest.CompFrequencyOffset = PerformanceTest.CompFrequencyOffset - 1;
            }

            //f_Defrosting = 1;  // 模拟外机 上传 除霜标志
            //set_manual_defrost( OFF );// 模拟外机 上传 除霜标志
        }
        else 
        {
            set_horSw( 0 );

            //f_Defrosting = 0;        // 模拟外机 上传 除霜标志
            //set_manual_defrost( ON );// 模拟外机 上传 除霜标志
        }

        /* iremote set light */
        set_light( buff_IR_MB[2 * 1 + 1].bit.b0 );

        /* iremote set sleep */
        set_sleep( buff_IR_MB[2 * 3 + 1].bit.b0 );

        /* iremote set health */
        set_health( buff_IR_MB[2 * 1 + 1].bit.b1 );

        /* iremote set keephum */
        // if (IR_Data04_b5 == 1)
        // {
        //     if (f_SetKeepHum == 1)
        //     {
        //         f_SetKeepHum = 0;
        //     }
        //     else
        //     {
        //         f_SetKeepHum = 1;
        //         f_code_HC = 1;
        //     }
        // }

        /* iremote set dryer */
        // set_dryer(IR_Data04_b4);

        /* iremote set heater */
        set_heater( buff_IR_MB[2 * 1 + 1].bit.b5 );
		
		HeaterCtrl();

        // stat_Disp888 = (IR_Data04 & 0x0C) >> 2;
        // if (IR_Custom != JUMPCUSTOM && IR_Data05_b6 == 1)
        // {
        //     temp.IFeel = (IR_Data05 & 0x3F) * 10;
        //     timer_IFeelSec = 660;
        // }
        // else
        // {
        //     temp.IFeel = 0;
        // }

        /* iremote set timerOn */
        if ( buff_IR_MB[2 * 0 + 1].bit.b6 && buff_IR_MB[2 * 0 + 1].bit.b5 )
        {
            set_timerOn( ( U16 ) ( buff_IR_MB[2 * 0 + 1].byte & 0x1F ) * 60 );
        }

        if ( PerformanceTest.PerformanceTestOccurFlag == 1 )
        {
            //set_heater(buff_IR_MB[2 * 1 + 1].bit.b5);
            AdjHor( buff_IR_MB[2 * 0 + 1].bit.b7 && buff_IR_MB[2 * 0 + 1].bit.b5 ); // 按下定时按键 ，导风角 减 调节
        }
        else 
        {
            /* iremote set timerOff */
            if ( buff_IR_MB[2 * 0 + 1].bit.b7 && buff_IR_MB[2 * 0 + 1].bit.b5 )
            {
                set_timerOff( ( U16 ) ( buff_IR_MB[2 * 0 + 1].byte & 0x1F ) * 60 );
            }
        }

        // if ((IR_Data09 & 0xF0) != 0x00)
        // {
        //     set_tarHum((U16)(((IR_Data09 & 0xF0) >> 4) + 3) * 50);
        // }

        /* iremote set humidifier */
        // set_humidifier(IR_Data09_b3);
        // f_wifi_rst = IR_Data09_b1;
        // f_wifi_test = IR_Data09_b0;

        /* iremote set call display */
        // if (IR_Data10_b2 == 1)
        // {
        //     if (CallDispMin == 0)
        //     {
        //         BuzzerAct(BUZZER400ms);
        //         CallDispMin = 5;
        //         if (parameter_out.indoorNum > 1)
        //         {
        //             dispTimer.adrr = 30;
        //         }
        //     }
        //     else
        //     {
        //         CallDispMin = 0;
        //     }
        // }

        /* iremote set no check dewing */
        // if (IR_Data10_b7 == 1)
        // {
        //     f_eepRomW = 1;
        //     if (f_SetNoCheckDewing == 1)
        //     {
        //         f_code_o6 = 0;
        //         f_SetNoCheckDewing = 0;
        //     }
        //     else
        //     {
        //         f_code_o6 = 1;
        //         f_SetNoCheckDewing = 1;
        //         BuzzerAct(BUZZER400ms);
        //     }
        // }

        /*      
               if ( buff_IR_MB[3].bit.b7 )
               {
                   if ( f_OutCSelf == 1 )
                   {
                       f_CleanSelf = 1;
                       stat_CleanSelf = CSELF_ACT;
                       BuzzerAct( BUZZER400ms );
                   }
               }
        */

        /* 

          iremote set cleanself
          温度过高条件,满足如下任一条件,不进入自清洁模式
            1 T内环 ＞ 38℃
            2 T外环 ＞ 43℃
            3 T内环 ＞ 30℃,且T外环 ＞ 40℃；
          温度过低条件,满足如下任一条件,不进入自清洁模式
            1 1.3.1T内环 ＜ 16℃；
            2 1.3.2T外环 ＜ 0℃；
        */
        if ( buff_IR_MB[3].bit.b7 == 1 )
        {
            //if ( ( temp.roomAct < 160 ) || ( temp.roomAct > 380 ) )
            //{
            //   ;
            // }
            //else 
            {
                if ( ( f_OutCSelf == 1 ) && ( PerformanceTest.PerformanceTestOccurFlag == 0 ) ) // 非性能测试的时候
                {
                    /*
                       外机的采集电路是：5V电压，下拉电阻方式：
                       采集到的AD值，除以4 就是 传给内机的 AD值：
                       AD 总共是 1024      传给内机是 是 uchar类型数据 还得除以 4 
                       下拉电阻5.1K：
                       5度 对应的 阻值是 10.97K --- 10.97+5.1==16.07  [（5.1/(16.07)）*1024]/4== 81
                       40度 对应的阻值 是 2.85K----2.85+5.1==7.95   [（5.1/(7.95)）*1024]/4== 164

                       下拉电阻10K：
                       5度 对应的 阻值是 10.97K    [（10/(10.97+10)）*1024]/4== 122
                       40度 对应的阻值 是 2.85K    [（10/(2.85+10)）*1024]/4== 199
                    */
                    // 5.1K
                    if ( CleanSelfData.CleanStartFlag == CleanOff ) // 自清洁运行过程中，再次接收到自清洁遥控开启信号时无效且不退出
                    {
#ifdef OutAdcSensor5_1K
                        if ( ( OutdoorMachine.AD_OutEnvironment >= 81 ) && ( OutdoorMachine.AD_OutEnvironment < 164 ) )
                        {
                            f_CleanSelf = 1;

                            //  stat_CleanSelf = CSELF_ACT;
                        }

#else

                        /*
                                                // 10K
                                                if ( ( OutdoorMachine.AD_OutEnvironment >= 122 ) && ( OutdoorMachine.AD_OutEnvironment < 199 ) )
                                                {
                                                    f_CleanSelf = 1;

                                                    // stat_CleanSelf = CSELF_ACT;
                                                }
                        */
                        if ( ( OutdoorMachine.AD_OutEnvironment >= AD_OutdoorMachine_OutEnvironment_5 ) && ( OutdoorMachine.AD_OutEnvironment < AD_OutdoorMachine_OutEnvironment_40 ) )
                        {
                            f_CleanSelf = 1;

                            //	stat_CleanSelf = CSELF_ACT;
                        }

#endif
                    }

                    BuzzerAct( BUZZER400ms );
                }
            }
        }

        /* iremote set no check fo */
        // if (IR_Data10_b5 == 1)
        // {
        //     f_eepRomW = 1;
        //     if (f_SetNoCheckFo == 1)
        //     {
        //         f_code_o4 = 0;
        //         f_SetNoCheckFo = 0;
        //     }
        //     else
        //     {
        //         f_code_o4 = 1;
        //         f_SetNoCheckFo = 1;
        //         BuzzerAct(BUZZER400ms);
        //     }
        // }

        /* iremote set force defrost */
        // if ((IR_Data10 & 0x03) == 0x03 && TestRunStat == 0 && f_OutErr_Ub == 0)
        // {
        //     set_manual_defrost(ON);
        //     BuzzerAct(BUZZER400ms);
        // }
        {
        }
        {
            static U8 RightLeftSwingCountFlag = 0;
            static U8 RightLeftSwingCountFlagPre = 0;

            if ( PerformanceTest.PerformanceTestOccurFlag == 0 )
            {
                if ( ( e_mode.set == MODECOOL ) || ( e_mode.set == MODEHEAT ) )
                {
                    if ( RightLeftSwingCountFlag != RightLeftSwingCountFlagPre )
                    {
                        PerformanceTest.RightLeftSwingCount++;
                        PerformanceTest.TenSecondCount = PerformanceTenSecond;
                        RightLeftSwingCountFlagPre = RightLeftSwingCountFlag;
                    }

                    if ( buff_IR_MB[2 * 3 + 1].bit.b4 == 0 )
                    {
                        set_horSw( 1 );
                        RightLeftSwingCountFlag = 0xFF;
                    }
                    else 
                    {
                        set_horSw( 0 );
                        RightLeftSwingCountFlag = 0x00;
                    }

                    if ( buff_IR_MB[2 * 3 + 1].bit.b7 == 0 ) // 摄氏温度
                    {
                        if ( e_mode.set == MODECOOL )
                        {
                            if ( ( l_tarTemp_C.set[MODECOOL] == 320 ) && ( e_mode.set == MODECOOL ) && ( e_fanStep.set[MODECOOL] == FANLEVEL6 ) ) // 性能测试的温度改成32 摄氏度
                            {
                                if ( PerformanceTest.RightLeftSwingCount >= 6 )
                                {
                                    PerformanceTest.PerformanceTestOccurFlag = 1;
                                    PerformanceTest.CoolInFanGear = 16;
                                    PerformanceTestInit_2(); // 每次 切换模式 时候 赋初值
                                }
                            }
                        }

                        if ( e_mode.set == MODEHEAT )
                        {
                            if ( ( l_tarTemp_C.set[MODEHEAT] == 160 ) && ( e_mode.set == MODEHEAT ) && ( e_fanStep.set[MODEHEAT] == FANLEVEL6 ) )
                            {
                                if ( PerformanceTest.RightLeftSwingCount >= 6 )
                                {
                                    PerformanceTest.PerformanceTestOccurFlag = 1;
                                    PerformanceTest.HeatInFanGear = 16;
                                    PerformanceTestInit_2(); // 每次 切换模式 时候 赋初值
                                }
                            }
                        }
                    }
                    else 
                    {
                        if ( e_mode.set == MODECOOL )
                        {
                            if ( ( l_tarTemp_C.set[MODECOOL] == 310 ) && ( e_mode.set == MODECOOL ) && ( e_fanStep.set[MODECOOL] == FANLEVEL6 ) )
                            {
                                if ( PerformanceTest.RightLeftSwingCount >= 6 )
                                {
                                    PerformanceTest.PerformanceTestOccurFlag = 1;
                                    PerformanceTest.CoolInFanGear = 16;
                                    PerformanceTestInit_2(); // 每次 切换模式 时候 赋初值
                                }
                            }
                        }

                        if ( e_mode.set == MODEHEAT )
                        {
                            if ( ( l_tarTemp_C.set[MODEHEAT] == 160 ) && ( e_mode.set == MODEHEAT ) && ( e_fanStep.set[MODEHEAT] == FANLEVEL6 ) )
                            {
                                if ( PerformanceTest.RightLeftSwingCount >= 6 )
                                {
                                    PerformanceTest.PerformanceTestOccurFlag = 1;
                                    PerformanceTest.HeatInFanGear = 16;
                                    PerformanceTestInit_2(); // 每次 切换模式 时候 赋初值
                                }
                            }
                        }
                    }
                }
            }

            if ( PerformanceTest.PerformanceTestOccurFlag == 1 )
            {
                if ( e_mode.set == MODEHEAT )
                {
                    switch ( l_tarTemp_C.set[MODEHEAT] )
                    {
                        case 160:
                            PerformanceTest.HeatInFanGear = 16;
                            break;

                        case 170:
                            PerformanceTest.HeatInFanGear = 15;
                            break;

                        case 180:
                            PerformanceTest.HeatInFanGear = 14;
                            break;

                        case 190:
                            PerformanceTest.HeatInFanGear = 13;
                            break;

                        case 200:
                            PerformanceTest.HeatInFanGear = 12;
                            break;

                        case 210:
                            PerformanceTest.HeatInFanGear = 11;
                            break;

                        case 220:
                            PerformanceTest.HeatInFanGear = 10;
                            break;

                        case 230:
                            PerformanceTest.HeatInFanGear = 9;
                            break;

                        case 240:
                            PerformanceTest.HeatInFanGear = 8;
                            break;

                        case 250:
                            PerformanceTest.HeatInFanGear = 7;
                            break;

                        case 260:
                            PerformanceTest.HeatInFanGear = 6;
                            break;

                        case 270:
                            PerformanceTest.HeatInFanGear = 5;
                            break;

                        case 280:
                            PerformanceTest.HeatInFanGear = 4;
                            break;

                        case 290:
                            PerformanceTest.HeatInFanGear = 3;
                            break;

                        case 300:
                            PerformanceTest.HeatInFanGear = 2;
                            break;

                        case 310:
                            PerformanceTest.HeatInFanGear = 1;
                            break;

                        case 320:
                            PerformanceTest.HeatInFanGear = 0;
                            break;

                        default:
                            PerformanceTest.HeatInFanGear = 10;
                            ;
                            break;
                    }
                }

                if ( e_mode.set == MODECOOL )
                {
                    switch ( l_tarTemp_C.set[MODECOOL] )
                    {
                        case 320:
                            PerformanceTest.CoolInFanGear = 16;
                        case 310:
                            PerformanceTest.CoolInFanGear = 15;
                            break;

                        case 300:
                            PerformanceTest.CoolInFanGear = 14;
                            break;

                        case 290:
                            PerformanceTest.CoolInFanGear = 13;
                            break;

                        case 280:
                            PerformanceTest.CoolInFanGear = 12;
                            break;

                        case 270:
                            PerformanceTest.CoolInFanGear = 11;
                            break;

                        case 260:
                            PerformanceTest.CoolInFanGear = 10;
                            break;

                        case 250:
                            PerformanceTest.CoolInFanGear = 9;
                            break;

                        case 240:
                            PerformanceTest.CoolInFanGear = 8;
                            break;

                        case 230:
                            PerformanceTest.CoolInFanGear = 7;
                            break;

                        case 220:
                            PerformanceTest.CoolInFanGear = 6;
                            break;

                        case 210:
                            PerformanceTest.CoolInFanGear = 5;
                            break;

                        case 200:
                            PerformanceTest.CoolInFanGear = 4;
                            break;

                        case 190:
                            PerformanceTest.CoolInFanGear = 3;
                            break;

                        case 180:
                            PerformanceTest.CoolInFanGear = 2;
                            break;

                        case 170:
                            PerformanceTest.CoolInFanGear = 1;
                            break;

                        case 160:
                            PerformanceTest.CoolInFanGear = 0;
                            break;

                        default:
                            PerformanceTest.CoolInFanGear = 10;
                            break;
                    }
                }

                fanSpeedSet();
            }
        }
        if ( b_power.set == OFF )
        {
            if ( PerformanceTest.PerformanceTestOccurFlag == 1 )
            {
                PerformanceTestClear();
            }
        }

        if ( IR_Custom == TESTCUSTOM )
        {
            f_SetCapTest = IR_Data10_b4;
            SetTestTimeMin = IR_Data11;
            SetTestTimeHour = IR_Data12;
        }
        else 
        {
            f_SetCapTest = 0;
            SetTestTimeMin = 0;
            SetTestTimeHour = 0;
        }

        TestRunSet();
        if ( IR_Custom == TESTCUSTOM )
        {
            TestStatSet();
            if ( CapTestStat != 0 && f_chg_verSw == TRUE ) // UD Swing Change
            {
                f_TestSwChg = 1;
            }
            else if ( CapTestStat == 0 )
            {
                f_TestSwChg = 0;
            }

            if ( SetFreValue != 0 && f_chg_fanstep == TRUE ) // Fan Change
            {
                f_TestFanChg = 1;
            }
            else if ( SetFreValue == 0 )
            {
                f_TestFanChg = 0;
            }
        }
        else 
        {
            ClrTestValue();
            FoRecallSet();
            tuya_app_set_test();
            tuya_app_show_data();
            if ( PowerOnMin < 2 && b_power.set == ON )
            {
                eepRomReset();
                TempRepairReset();
                if ( ( IR_Data01 & 0x70 ) == 0x60 )
                {
                    JumpTypeReset( IR_Data11 );
                }

                // tarTemp_limit_set(); //屏蔽掉酒店模式
            }
        }

        /* 只要收到遥控就清 */
        if ( f_FilterClean == TRUE )
        {
            f_FilterClean = FALSE;
        }

        if ( f_CleanSelf == 0 ) //  自清洁的时候 不进行记忆 cxs  20250225
        {
            f_eepRomChg = 1;
        }

        CtrlEndTime = 0;

#ifdef CTRL_485
        update_wireCtrl = 2;
#endif

        IRemote_Init();
    }
}


void IRemoteCheck( void ) /* 红外遥控接收校验 */
{
    U8      i, n, local_byte, local_interval, local_CheckSum;

    n       = ( IR_Code01 & 0xF0 ) >> 4;
    local_interval = n - 1;
    local_byte = n * 8 + 1;
    if ( ir_Rec.byte == local_byte && ir_Rec.interval == local_interval )
    {
        for ( i = 0; i <= local_interval; i++ )
        {
            local_CheckSum = 0;
            if ( i == 0 )
            {
                for ( n = 0; n <= 7; n++ )
                {
                    local_CheckSum += buff_IR[n].byte;
                }
            }
            else 
            {
                for ( n = i * 8 + 1; n <= i * 8 + 7; n++ )
                {
                    local_CheckSum += buff_IR[n].byte;
                }
            }

            local_CheckSum ^= 0xAA;
            if ( ( buff_IR[8 * i + 1].byte & 0x0F ) == ( i + 1 ) && buff_IR[8 * i + 8].byte == local_CheckSum )
            {
                irCheck |= ( 0x01 << i );
            }
            else 
            {
                IRemote_Init();
                return;
            }
        }
    }

    if ( ir_Rec.byte >= IREMOTEMAX_MB && buff_IR_MB[11].byte == 0x55 )
    {
        if ( ( ( buff_IR_MB[0].byte + buff_IR_MB[1].byte ) == 0xFF ) && ( ( buff_IR_MB[2].byte + buff_IR_MB[3].byte ) == 0xFF ) && ( ( buff_IR_MB[4].byte + buff_IR_MB[5].byte ) == 0xFF ) && ( ( buff_IR_MB[6].byte + buff_IR_MB[7].byte ) == 0xFF ) &&
             ( ( buff_IR_MB[8].byte + buff_IR_MB[9].byte ) == 0xFF ) && ( ( buff_IR_MB[10].byte + buff_IR_MB[11].byte ) == 0xFF ) )
        {
            f_irCheck3 = 1;
        }
    }
}


